from core.support import set_cutscene, get_game
from core.item import Item
from core.action import Action
from core.game import Game

class Mary(Item):
    def __init__(self):
        Item.__init__(self, "mary")    # do basic initialization for every item
        
        # build list of actions
        # are we going to do a swipe action?  or just check if the card is in inventory?
        # if we just check, then we don't need this action at all
        self.add_action(UseMary)
    
    def get_description(self):
        return "Mary Sforza"
# added using concept from OILCAN.PY
class UseMary(Action):
    def __init__(self):
        Action.__init__(self, "use_mary")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Mary"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    # only show button if Neil is in inventory
    
    def is_enabled(self):
        game = get_game()
        player = game.get_player()
        # only shows up in council room
        if game.history[-1].get_id() == 'ballroom':
            # only works if you have Neil in inventory    
            if ('mary' in player.inventory):
                return False
            else: 
                return False
        else:
            return False
        
               
# only works in council room . 
    def do_action(self,game,room,request):
        if game.history[-1].get_id() != 'ballroom':
            if room.locked:
                room.locked = False
            else:           
                set_cutscene("You're just a measly grad student.  You can't get up to the 9th floor ballroom.  Find someone who has the keys, punk.")
        else:
            set_cutscene("What do you want to use Mary for?")

        return